package com.swt;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.swt.domain.*;
import com.swt.service.*;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * @Description
 * @Author swt
 * @Date 2022/5/16
 */
@SpringBootTest
public class text {

    @Autowired
    private GoodsService goodsService;
    @Test
    void textin(){
        for (int i = 0; i < 20; i++) {
            Goods goods = new Goods();
            goods.setGoodsName("菠萝"+i);
            goods.setGoodsDesc("大");
            goods.setGoodsAttribute("水果");
            int d =goodsService.inserGoods(goods);
            System.out.println(d>0 ?"成功":"失败");
        }

    }

    @Test
    void sele(){
        List<Goods> a = goodsService.selectAllGoods();
        for (com.swt.domain.Goods Goods : a) {
            System.out.println(Goods);
        }
    }
    @Test
    void dele1(){
        int i = goodsService.delectGoods("1526134605281775618");
        System.out.println(i>0 ?"成功":"失败");
    }
    @Test
    void creat0(){
        Goods Goods = new Goods();
        Goods.setGoodsName("草莓");
        Goods.setId("1526198855320825858");
        int i = goodsService.updateGoods(Goods);
        System.out.println(i>0 ?"成功":"失败");
    }
    @Test
    void  select1(){
        Goods i = goodsService.selectbyGoodid("1526134608746270721");
        System.out.println(i);
    }
    @Autowired
    private GoodsCommentService goodsService02;
    @Test
    void creat01(){
        for (int i = 0; i < 30; i++) {
            GoodsComment goods =  new GoodsComment();
            goods.setCommentGoodsId(1+i);
            goods.setCommentBuyer("校长");
            goods.setCommentDesc("好很好");
            goods.setCommentRank(1);
            int ii = goodsService02.inserGoodsComment(goods);
            System.out.println(ii>0 ?"成功":"失败");
        }


    }
    @Test
    void select01(){
        GoodsComment i = goodsService02.selectbyGoodsCommentid("1526201196245798913");
        System.out.println(i);
    }
    @Test
    void dele01(){
        int i  = goodsService02.delectGoodsComment("1526201196245798913");
        System.out.println(i>0? "成功":"失败");
    }
//    @Test
//    void page02(){
//    Page<GoodsComment> page = goodsService02.pageGoodsComment(1,10);
//        System.out.println(page);
//
//    }
    @Test
    void update02(){
        GoodsComment k =  new GoodsComment();
        k.setId("1526201199408304130");
        k.setCommentBuyer("擦汗");
        int i = goodsService02.updateGoodsComment(k);
        System.out.println(i>0? "成功":"失败");
    }
    @Autowired
    private AdminService adminService;

    @Test
    void sele03(){
        List<Admin> i = adminService.selectAlladmin();
        System.out.println(i);
    }
    @Test
    void inster03(){
        for (int i = 0; i < 30; i++) {
            Admin a = new Admin();
            a.setUsername("小明"+i);
            a.setLoginPwd("123456");
            a.setMobile("1388888888");
            int b = adminService.inseradmin(a);
            System.out.println(b>0? "成功":"失败");
        }


    }
    @Test
    void dele02(){
        int i = adminService.delectadmin("1");
        System.out.println(i>0? "成功":"失败");

    }
//    @Test
//    void page03(){
//        Page<Admin> a = adminService.pageadmin(3,5);
//        System.out.println(a);
//    }
    @Test
    void update03(){
        Admin a = new Admin();
        a.setUsername("admin");
        a.setId("3");
        a.setLoginPwd("129786");
        a.setMobile("15661552419");
        int i =adminService.updateadmin(a);
        System.out.println(i>0? "成功":"失败");


    }
    @Test
    void seleone01(){
        Admin a = adminService.selectbyadmin("2");
        System.out.println(a);
    }
    @Autowired
    private CartService cartService;
    @Test
    void inster04(){
        for (int i = 0; i < 30; i++) {
            Cart a = new Cart();
            a.setUserId(i);
            int S =cartService.inserCart(a);
            System.out.println(S);

        }
    }
    @Test
    void Date(){
        int i =cartService.delectCart("1526219781424840707");
        System.out.println(i>0? "成功":"失败");

    }
    @Test
    void update04(){
        Cart a = new Cart();
        a.setId("1526219781554864131");
        a.setGoodsId(10010);
        int i =cartService.updateCart(a);
        System.out.println(i>0? "成功":"失败");

    }
    @Test
    void select04(){
        Cart a = cartService.selectbyidCart("1526219781554864131");
        System.out.println(a);
    }
    @Autowired
    private OrderDetailService detailService;
    @Test
    void inster05(){


        for (int i = 0; i < 20; i++) {
            OrderDetail a = new OrderDetail();
            a.setUserId(i);
            a.setOrderId(1);
            a.setGoodsId(1);
            int b = detailService.inserDetail(a);
            System.out.println(b);
        }

    }
    @Test
    void select05(){
        List<OrderDetail> a= detailService.selectAllDetail();
        System.out.println(a);
    }
    @Test
    void update05(){
        OrderDetail a = new OrderDetail();
        a.setId("1526357167236521986");
        a.setBuyNumber(132456);
        a.setPrice(10.25);
        int i = detailService.updateDetail(a);
        System.out.println(i>0? "成功":"失败");
    }
    @Test
    void dele05(){
        int i = detailService.delectDetail("1526357167362351105");
        System.out.println(i>0? "成功":"失败");

    }
    @Test
    void selectone05(){
        OrderDetail a = detailService.selectbyidDetail("1526357167236521986");
        System.out.println(a);
    }
    @Autowired
    private  TbManageUserService UserService;
    @Test
    void inster06(){
        for (int i = 0; i < 30; i++) {
            TbManageUser a = new TbManageUser();
            a.setName("张三");
            a.setUsername("隔壁小王"+i);
            a.setPassword("123456");
            a.setPhone("1388888888");
            a.setEmail("1388888@QQ.COM");
            int b = UserService.inserUser(a);
            System.out.println(b>0? "成功":"失败");

        }
    }
    @Test
    void selectall(){
        List<TbManageUser> a = UserService.selectAllUser();
        System.out.println(a);
    }
    @Test
    void selectone(){
        TbManageUser a = UserService.selectbyuserid("1526364000240115713");
        System.out.println(a);
    }
    @Test
    void update06(){
        TbManageUser a = new TbManageUser();
        a.setUsername("小王八");
        a.setId("1526364000240115713");
        int i = UserService.updateUser(a);
        System.out.println(i>0? "成功":"失败");
    }
    @Test
    void dele06(){
        int i = UserService.delectUser("1526364000240115713");
        System.out.println(i>0? "成功":"失败");
    }
    @Autowired
    private TbUserService userService;
    @Test
    void inster07(){
        for (int i = 0; i < 20; i++) {
            TbUser a = new TbUser();
            a.setAge(21);
            a.setPaypassword(123456);
            a.setName("葫芦"+i+"娃");
            a.setPhone("138888888");
            a.setEmail("129786@qq.com");
            a.setPassword("swt123456");
            int b =userService.inserTbUser(a);
            System.out.println(b>0? "成功":"失败");
        }
    }
    @Test
    void selectAllUser(){
        List<TbUser> a =userService.selectAllTbUser();
        System.out.println(a);
    }
    @Test
    void selectone02(){
        TbUser a = userService.selectbyTbUser("1526378156984983554");
        System.out.println(a);
    }
    @Test
    void update07(){
        TbUser a = new TbUser();
        a.setName("小小套娃");
        a.setId("1526378157245030401");
        a.setPhone("15661552419");
        int i = userService.updateTbUser(a);
        System.out.println(i>0? "成功":"失败");
    }
    @Test
    void  dele007(){
        int i =userService.delectTbUser("1526378157245030401");
        System.out.println(i>0? "成功":"失败");
    }
//    @Test
//    void page07(){
//        Page<TbUser> a = userService.pageTbUser(1,5);
//        System.out.println(a);
//    }

    @Autowired
    private TbUserAddrService addrService;
    @Test
    void inster08(){
        for (int i = 0; i < 30; i++) {
            TbUserAddr a =new TbUserAddr();
            a.setUserId("007");
            a.setReceiverName("汪汪"+i+"小小酥");
            a.setReceiverMobile("15661552419");
            a.setReceiverState("内蒙古");
            a.setReceiverCity("包头市");
            a.setReceiverDistrict("昆都仑区");
            a.setReceiverAddress("海威小区八区");
            a.setReceiverZip("014010");
            int b = addrService.inserUserAddr("123123123",a);
            System.out.println(a);
        }
    }
    @Test
    void select08(){
        List<TbUserAddr> a = addrService.selectAllUserAddr();
        System.out.println(a);
    }
    @Test
    void updeate08(){
        TbUserAddr a = new TbUserAddr();
        a.setReceiverName("苏喂苏喂");
        a.setId("1526391069560926209");
        int b =addrService.updateUserAddr(a);
        System.out.println(b>0? "成功":"失败");
    }
//    @Test
//    void selectone08(){
//        TbUserAddr a = addrService.selectbyUserAddrdid("1526391069560926209");
//        System.out.println(a);
//    }
    @Test
    void detailSer(){
        int i = addrService.delectUserAddr("1526391073616818178");
        System.out.println(i>0? "成功":"失败");
    }
    @Test
    void page08(){
        Page<TbUserAddr> A = addrService.pageUserAddr(1,8);
        System.out.println(A);
    }
}
